<?php
function microtime_float(){
    list($usec,$sec) = explode(" ",microtime());
    return ((float)$usec + (float)$sec);
}

function log_data($str){
    $fp = fopen("test.csv",'w');
    fwrite($fp,"rtt\n");
    fwrite($fp,$str);
    fclose($fp);
}

$url="http://localhost:8080/DataValidation/rest/validate/check/";
$str="";
$post_data = array( 
	"holder_phone_mobile"=>"13950554313" ,
	"holder_phone"=>"2701111" ,
	"holder_phone_area"=>"022" ,
	"holder_email"=>"my_email@126.com.cn" ,
	"holder_name"=>"abc" ,
	"holder_birthday"=>"1989-11-11" ,
	"holder_gender"=>"1" ,
	"holder_card_type"=>"1" ,
	"holder_card_no"=>"340822198911114612" ,
	"effective_date"=>"2013-01-29" ,
	"contact_relation-0"=>"1" , 
	"contact_name-0"=>"hello-0" , 
	"contact_ratio-0"=>"25" ,
	"contact_relation-1"=>"1" , 
	"contact_name-1"=>"hello-1" , 
	"contact_ratio-1"=>"25" ,
	"contact_relation-2"=>"1" , 
	"contact_name-2"=>"hello-2" , 
	"contact_ratio-2"=>"25" ,
	"contact_relation-3"=>"1" , 
	"contact_name-3"=>"hello-3" , 
	"contact_ratio-3"=>"25"
);

foreach($post_data as $k=>$v){
	$str.="$k=".urlencode($v)."&";
}

$post_data=substr($str,0,-1);
$ch=curl_init();
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_HEADER,0);
curl_setopt($ch,CURLOPT_COOKIEJAR,"cookie.txt");
curl_setopt($ch,CURLOPT_POSTFIELDS,$post_data);
$cnt=1;
$res="";
while($cnt <= 5){
    $temp_url=$url."".$cnt;
    //echo $temp_url."\n";
    curl_setopt($ch,CURLOPT_URL,$temp_url);
    $micro_time_start = microtime_float();
    $result=curl_exec($ch);
    $micro_time_end = microtime_float();
    $micro_time = $micro_time_end - $micro_time_start;
    $res.=$micro_time."\n";
    $cnt++;
}
log_data($res);
?>
